package com.woniu.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 购物车列表项
 * */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CartItemVo {
    private Long userId; //用户id
    private Long bookId; //图书id
    private String press; //出版社
    private String name; //书名
    private String image; //图书图片
    private Double price; //单价
    private Integer quantity; //数量
    private Double sum; //金额

    //带部分参数的构造器
    public CartItemVo(Long userId, Long bookId, String name, String image, Double price,
                      Integer quantity) {
        this.userId = userId;
        this.bookId = bookId;
        this.name = name;
        this.image = image;
        this.price = price;
        this.quantity = quantity;
    }
    //计算金额的方法
    public Double getSum() {
        return price * quantity;
    }
}
